<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;
//use App\Model\Admin\Admin;
class UserController extends Controller
{
    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
   
        $data = DB::table('user')->get();
        return view('admin.user_list',['user'=>$data]);
       
       
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
       // return view('admin.admin_create');
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //

    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
        $user = DB::table('user')->where('id',$id)->first();
        return view('admin.user_show',['user'=>$user]);
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
       // return view('admin.admin_edit',['id'=>$id]);
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
   
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
    //删除用户
    public function del($id)
    {
      /*return $id;
        die;*/
        DB::table('user')->where('id',$id)->delete();
        return response()->json(['status' => '200']);
    }
    //禁用用户
    public function stop($id)
    {
       $res =  DB::table('user')->where('id',$id)->update(['status'=>1]);
       if($res){
        return response()->json(['status' => '200']);
       }

    }

    //启用用户
    public function start($id)
    {
       $res =  DB::table('user')->where('id',$id)->update(['status'=>0]);
       if($res){
        return response()->json(['status' => '200']);
       }

    }
 
}